/*
 * PSDetectObstaclesBlobfinder.java
 *
 * Created on 17 de febrero de 2008, 08:27 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package nx2.behaviors;

import nx2.robot.*;
import nx2.utils.*;
import javaclient2.*;
import javaclient2.structures.blobfinder.*;


/**
 * Class implementing a Perception Schema (PS) for dealing with blobfinder readings.
 *
 * This class converts blofinder readings into vector readings, for easy use with Motor Schemas (MS).
 *
 * @author Alejandro Pustowka
 */
public class NxPSDetectObstaclesBlobfinder extends NxPSDetectObstacles {

    //private Blobfinder bf;
    private BlobfinderInterface bf;
    private float radius;
    private Position2DInterface pos;
    
    //TODO: Corregir, no se le deberia pasar el radio. Los vectores devuletos por el blobfinder ya deben tener en cuenta
    //el tamaño del objeto, es decir, no estar referenciados respecto a su centro, sino respecto al punto mas cercano en 
    //la dirección del robot
    /**
     * Creates a Perception Schema based on Blobfinder readings.
     *
     * The output of this schema is an Array of Vector2D, each referenced to
     * the robots origin. That means, this schema is heavily based on localization
     * information. It has to be used with a Position2DInterface. In coming versions,
     * this could be fixed.
     * @param name Name of this Schema.
     * @param pos The Position2DInterface of Jaclient, from where the localization will be known.
     * @param bf The BlobfinderInterface of Javaclient, from where the readings come.
     * @param radius Radius of the objects found.
     */
    public NxPSDetectObstaclesBlobfinder(String name,Position2DInterface pos,BlobfinderInterface bf, float radius) {
        super(name);
        
        //Assign Player Interfaces
        this.bf = bf;
        this.radius = radius ;
        this.pos = pos;


        
    }
    
    public Vector2D[] value() {
        

        //get data from Blobfinder
        PlayerBlobfinderData dataBF = bf.getData();

        //get number of blobs detected
        numReadings = dataBF.getBlobs_count();

        //get the regarding information of the detected blobs
        PlayerBlobfinderBlob[] blobs = dataBF.getBlobs();

        //create the array of data
        data = new Vector2D[numReadings];

        
       
            for(int i= 0;i<numReadings;i++)
            {
                data[i] = new Vector2D();

                //TODO: Esto hay que colocarlo!!!!

            }
       
            
        return data;
    }
}